package sparksql

import org.apache.spark.sql.SparkSession

object DataFrameApp {

  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder().appName("SparkSessionApp").master("local[2]").getOrCreate();
    val person = spark.read.json("F:\\lzc\\SparkSQL\\sparksql\\src\\main\\scala\\com\\lzc\\people.json");

    // person.printSchema();
    person.show();
    // select name from table
    person.select("name").show();
    // select name,age+10 as age2 from table
    person.select(person.col("name"),(person.col("age")+10).as("age2")).show();
    // select * from table where age > 20
    person.filter(person.col("age") > 20).show();
    //
    person.groupBy("age").count().show();
  }
}
